  using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections.Generic;

namespace project.articulos_dir
{
    public partial class listado_articulos : System.Web.UI.Page
    {
        private void seguridad()
        {
            if (sf.cadena(HttpContext.Current.Session["adminhondaab1"]) == "")
            {
                //Sales..
                Response.Redirect("../../portal/market/main_market.aspx");
            }

        }
        protected void Page_Load(object sender, EventArgs e)
        {
            seguridad();



            int novedad = 0;
            int ofertas = 0;
            int todos = 0;
            if (chkNovedad.Checked)
            {
                novedad = 1;
            }
            if (chkOfertas.Checked)
            {
                ofertas = 1;
            }
 



 
            List<articulos> lista = new List<articulos>();
          
            if (!Page.IsPostBack)
            {
                List<marcas> listamarcas = new List<marcas>();
                listamarcas = marcas.getList();
                Repeatermarcas.DataSource = listamarcas;
                Repeatermarcas.DataBind();
             
                

                // lista = articulos.getList();
                List<categoriasarticulos> listaCats = new List<categoriasarticulos>();
                listaCats = categoriasarticulos.getList();

                //foreach (categoriasarticulos cate in listaCats)
                //{
                //    cate.bol5 = articulos.getListarticulosByCatsByMarcas(cate.idcategoriasarticulos, idmarcas).Count;
                //}

                RepeaterChekers.DataSource = listaCats;
                RepeaterChekers.DataBind();

            }
            List<string> Lmarcas = new List<string>();
           // List<string> Ltemporadas = new List<string>();
            List<string> LcategoriasArticulos = new List<string>();
            //foreach (RepeaterItem i in Repeatertempo.Controls)
            //{
            //    CheckBox chk1 = (CheckBox)i.FindControl("chk");
            //    string idtempo = "";

            //    if (chk1 != null)
            //    {
            //        if (chk1.Checked)
            //        {
            //            idtempo = chk1.CssClass.ToString();
            //            Ltemporadas.Add(idtempo);

            //        }


            //    }
            //}
            foreach (RepeaterItem i in Repeatermarcas.Controls)
            {
                CheckBox chk1 = (CheckBox)i.FindControl("chk");
                string idmarcas1 = "";

                if (chk1 != null)
                {
                    if (chk1.Checked)
                    {
                        idmarcas1 = chk1.CssClass.ToString();
                        Lmarcas.Add(idmarcas1);

                    }


                }
            }
            foreach (RepeaterItem i in RepeaterChekers.Controls)
            {
                CheckBox chk1 = (CheckBox)i.FindControl("chk");
                string idcategoriasarticulos = "";

                if (chk1 != null)
                {
                    if (chk1.Checked)
                    {
                        idcategoriasarticulos = chk1.CssClass.ToString();
                        LcategoriasArticulos.Add(idcategoriasarticulos);

                    }


                }
            }
            lista = articulos.getListByCategoriasMarcas(LcategoriasArticulos, Lmarcas, txtBusqueda.Text, novedad,ofertas);
            Repeater1.DataSource = lista;
            Repeater1.DataBind();


        }
        protected void Repeatercats_ItemCommand(object sender, RepeaterCommandEventArgs e)
        {
            //   CheckBox bot1 = (CheckBox)thisFindControl(camp.idcolores.ToString());
            string id = sf.cadena(e);
            //   string accion = e.CommandName.ToString();
        }
        protected void RepeaterChekers_ItemCommand(object sender, RepeaterCommandEventArgs e)
        {
            //   CheckBox bot1 = (CheckBox)thisFindControl(camp.idcolores.ToString());
            string id = sf.cadena(e);
            //   string accion = e.CommandName.ToString();
        }
        protected void Repeatertempo_ItemCommand(object sender, RepeaterCommandEventArgs e)
        {
            //   CheckBox bot1 = (CheckBox)thisFindControl(camp.idcolores.ToString());
            string id = sf.cadena(e);
            //   string accion = e.CommandName.ToString();
        }
        protected void btnBuscar_Click(object sender, EventArgs e)
        {
            List<articulos> lista = new List<articulos>();
            lista = articulos.getListByBusquedaGeneral(txtBusqueda.Text);
            Repeater1.DataSource = lista;
            Repeater1.DataBind();
        }
  
  
    }
}
